package com.manpower.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.manpower.dao.dataobject.UserDto;
import com.manpower.dao.mapper.UserDtoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class TestUserService {

    @Autowired
    private UserDtoMapper userDtoMapper;

    public String getUser(Integer id){
        //UserDto userDto = userDtoMapper.selectById(id);
        UserDto userDto = new UserDto();
        userDto.setUserName("我是胖勇！");
        String userName = userDto.getUserName();
        return userName;
    }

    public List<UserDto> getUser2(String userName){
        List<UserDto> userList = userDtoMapper.getUserByName(userName);

        return userList;
    }

    public IPage<UserDto> postUserList(UserDto userDto, Integer page, Integer limit) {
        Page<Map<String,Object>> p = new Page<Map<String,Object>>(page,limit);
        IPage<UserDto> userList =  userDtoMapper.postUserList(p,userDto);
        return userList;
    }
}
